
package controllers;
import vos.*;
import play.db.jpa.Transactional;
import play.libs.Json;
import sanduche.play.shared.SanController;
import play.mvc.Http.Request;
import play.mvc.Http.Response;
import play.mvc.Http.Session;
import play.mvc.Result;
import models.*;
public class UserController extends SanController {
	@Transactional(readOnly=true)
	public static Result getMyInfo(){
		try{
			Session session = session();
			return ok(Json.toJson(sanduche.controllers.UserController.getMyInfo(session)));
		}catch(Throwable e){return parseError(e);}
	}
 
	@Transactional(readOnly=true)
	public static Result login(){
		try{
			LoginCredentials body = Json.fromJson(request().body().asJson(),LoginCredentials.class);
			Session session = session();
			sanduche.controllers.UserController.login(body, session);return ok();
		}catch(Throwable e){return parseError(e);}
	}
 
	@Transactional
	public static Result saveAndroidId(String idAndroid){
		try{
			Session session = session();
			sanduche.controllers.UserController.saveAndroidId(session, idAndroid);return ok();
		}catch(Throwable e){return parseError(e);}
	}
 
	
	public static Result logout(){
		try{
			Session session = session();
			sanduche.controllers.UserController.logout(session);return ok();
		}catch(Throwable e){return parseError(e);}
	}
 
	@Transactional
	public static Result getPersonasConDocumento(String documento){
		try{
			
			return ok(Json.toJson(sanduche.controllers.UserController.getPersonasConDocumento(documento)));
		}catch(Throwable e){return parseError(e);}
	}
}